<?php

namespace app\api\model;

use app\api\extend\ModelCommon;

/**
 * 视频模型
 */
class Video extends ModelCommon {
	/**
	 * 添加视频
	 * @param $data 
	 */
	public function add($data) {
		return $this->save($data);
	}
	/**
	 * 获取视频
	 */
	public function list($data) {
		if ($this->isKeyInArr('video_uid',$data) && $this->isKeyInArr('video_id',$data)) {
            return $this->where($data)->field($this->getFilesStr())->find();
        }elseif ($this->isKeyInArr('video_id',$data)) {
			return $this->where($data)->field($this->getFilesStr())->find();
		}elseif ($this->isKeyInArr('video_uid',$data) ) {
			return $this->where($data)->field($this->getFilesStr())->select();
		}else {
			return $this->field($this->getFilesStr())->select();
		}
	}

	/**
	 * 删除视频
	 */
	public function del($data) {
		return $this->where('video_uid', $data['video_uid'])
			->where('video_id', 'in', $data['video_id'])->delete();
	}

	/**
	 * 修改视频
	 */
	public function upd($data) {
		return $this->where('video_uid',$data['video_uid'])
			->where('video_id', $data['video_id'])
			->save($data['data']);
	}

}
